﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class Changer{
    /// <summary>
    /// hurt伤害
    /// sv射速
    /// uCount数量
    /// cd冷却时间
    /// error偏差
    /// info提示
    /// </summary>
    /// <param name="cmd"></param>
    /// <param name="hurt"></param>
    /// <param name="uCount"></param>
    /// <param name="cd"></param>
    /// <param name="error"></param>
    /// <param name="info"></param>
    private static void Modify(MenuCommand cmd, int hurt, float sv, int uCount, float cd, float error, string info,int index,Shot shot=Shot.RAY)
    {
        LazerGun lazerGun = cmd.context as LazerGun;
        lazerGun.lazerDamage.Hurt = hurt;//狙击枪的伤害
        lazerGun.useCount = uCount;//子弹数
        lazerGun.cdTime = cd;
        lazerGun.errorshot = error;
        lazerGun.shotVelocity = sv;
        lazerGun.info = info;
        
        if(shot!=Shot.RAY)
        {
            lazerGun.shotType = shot;
        }

        var a = GameObject.Find("GameManager").GetComponent<ResourceManager>();
        var b = a.propSources[index];
        var c = b.GetComponent<SpriteRenderer>();
        Selection.activeTransform.GetChild(0).GetComponent<SpriteRenderer>().sprite =c.sprite;
    }

    [MenuItem("CONTEXT/LazerGun/Sniper_rifle")]
    static void Sniper_rifle(MenuCommand cmd)
    {
        Modify(cmd,3,10,15,2f,0.2f,"精准狙击枪，威力大，准度高",8,Shot.Sniper_gun);
        
    }


    [MenuItem("CONTEXT/LazerGun/Pistol")]
    static void Pistol(MenuCommand cmd)
    {
        Modify(cmd, 1,5, -1, 1f, 0.2f,"小型手枪，无限子弹",10);
    }

    [MenuItem("CONTEXT/LazerGun/Machine_Gun")]
    static void Machine_Gun(MenuCommand cmd)
    {
        Modify(cmd, 1,8, 60,0, 1.2f, "重型机枪，无冷却，子弹多",9);
    }

}
